﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Clandestine.Entities
{
    public class Door : Entity
    {
        private string destinationMap = string.Empty;
        public string DestinationMap
        {
            get { return destinationMap; }
            set { destinationMap = value; }
        }
        private string destinationEntrance = string.Empty;
        public string DestinationEntrance
        {
            get { return destinationEntrance; }
            set { destinationEntrance = value; }
        }
        public override bool CanUse
        {
            get { return true; }
        }
        private string metaFilename = "sprite_metadata/door.xml";
        public string MetadataFilename
        {
            get { return metaFilename; }
            set 
            {
                animSprite.ClearAnimations();
                animSprite.AddAnimations(spriteFilename, metaFilename);
            }
        }
        private string spriteFilename = "rpgmaker/exterior/doors2_tiles.png";
        public string SpriteFilename
        {
            get { return spriteFilename; }
            set
            {
                animSprite.ClearAnimations();
                animSprite.AddAnimations(spriteFilename, metaFilename);
            }
        }
        AnimatedSprite animSprite = new AnimatedSprite();
        public override Sprite Sprite
        {
            get { return (Sprite)animSprite; }
        }

        public Door()
        {
            animSprite.AddAnimations(spriteFilename, metaFilename);
        }

        public override void Dispose()
        {
            animSprite.Dispose();
        }

        public override void OnUse(int playerXPos, int playerYPos)
        {
            // door animation
            animSprite.SetAnimation("open");
            animSprite.StartAndWait();

            WorldMap.ChangeLevel(DestinationMap, DestinationEntrance);
        }
    }
}
